package com.mzp.XbShop.mapper;

import com.mzp.XbShop.common.entity.Result;
import com.mzp.XbShop.pojo.Goods;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @Description goods 数据访问接口
 * @date 2021-04-17 15:04:51
*/
public interface GoodsDao extends JpaRepository<Goods,String>,JpaSpecificationExecutor<Goods>{

    Goods[] findTop4ByStatusOrderByPublishdateDesc(String s);

    List<Goods> findTop4ByStatusOrderByVisitDesc(String s);

    List<Goods> findBygroupid(String groupid);

//    List<Goods> findByTitleLikeAndDescLike(String title,String title1);

    List<Goods> findByTitleLike(String title);

    @Modifying
    @Query("update Goods a set a.visit=a.visit+1 where a.id=?1")
    Integer updateVisitors(String id);
}

